﻿// Copyright Microsoft

using System;
using System.Windows;
using System.Windows.Controls;
using System.Activities.Presentation.View;
using System.Activities.Presentation;
using System.Activities.Statements;
using System.Collections.ObjectModel;
using System.Activities.Presentation.Model;
using Microsoft.Samples.SqlServer.ExtensionMethods;
using System.Activities;
using System.Net;
using System.Linq;

namespace Microsoft.Samples.SqlServer.Activities.Designers
{ 
  public partial class LoginFormActivityDesigner
  {
        public LoginFormActivityDesigner()
        {
            InitializeComponent();
        }

        private void ActivityDesigner_Loaded(object sender, RoutedEventArgs e)
        {
            //NOTE: The sample assumes a Sequence Credentials variable as ICredential
            Sequence rootSequence = this.ModelItem.RootSequence() as Sequence;
            if (rootSequence != null)
            {
                this.ModelItem.Properties["NetworkCredential"].SetValue(new OutArgument<ICredentials>(
                (from v in rootSequence.Variables
                 where v.Name == "Credentials"
                 select v).First()));

            }
        }
  }
}
